




var _oSCVConst =
{

regexpSchemaNameChars:		RegExp('[A-Za-z0-9_]', 'g')
};








var _oSCVErrors =
{
sCannotBeBlank:				LOCID_SYSCUST_CANTBEBLANK,
sCannotHaveInvalidChars:	LOCID_SYSCUST_INVALCHARS,
sCanOnlyHaveAlphaNumerics:	LOCID_SYSCUST_ALPHANUMSONLY
};














function validateName(txtName, oValidCharsRegExp, sError_InvalidCharsFormat, sError_InvalidChars)
{
var sMessage, sName;



if (sError_InvalidChars == null)
{
sError_InvalidChars = "";
}


sName= txtName.DataValue;


if (sName == null || sName == "")
{
sMessage = _oSCVErrors.sCannotBeBlank;
}

else if (sName.replace(oValidCharsRegExp, "") != "")
{
sMessage = sError_InvalidCharsFormat;
}

else
{
return true;
}


alert(formatString(sMessage, getControlName(txtName), sError_InvalidChars));
setControlFocus(txtName);
return false;
}





function validateSchemaName(txtName)
{
return validateName(txtName,
_oSCVConst.regexpSchemaNameChars,
_oSCVErrors.sCanOnlyHaveAlphaNumerics);
}






function validateRequiredValue(oControl)
{
if (!oControl.Disabled)
{
var oValue = oControl.DataValue;

if (oValue == null || typeof(oValue) == "string" && oValue == "")
{
alert(formatString(_oSCVErrors.sCannotBeBlank, getControlName(oControl)));
setControlFocus(oControl);
return false;
}
}

return true;
}






function validateRequiredInput(oControl, sLabel)
{

var oValue = oControl.value;
if (oValue == null || typeof(oValue) == "string" && oValue == "")
{
setControlFocus(oControl);
alert(formatString(_oSCVErrors.sCannotBeBlank, sLabel));
return false;
}

return true;
}

















function getControlName(oControl)
{
return window.document.all(oControl.id + "Label").innerText;
}





function setControlFocus(oControl)
{

var oParent = oControl.parentNode;
do
{
if (oParent == null || oParent.className == "ms-crm-Tab")
{
break;
}
oParent = oParent.parentNode;
}
while (1);
if (oParent != null)
{
var oTab = document.all(oParent.id + "Tab");
oTab.click();
}


try
{
oControl.SetFocus();
}
catch (ex)
{
oControl.focus();
}
}

